//
//  XSHttp.m
//  小说
//
//  Created by WZH on 2018/5/28.
//  Copyright © 2018年 WZH. All rights reserved.
//

#import "XSHttp.h"

@implementation XSHttp

+ (void)httpWithStartNumber:(NSString *)startNum backDataArray:(void (^)(SmallModel *))dataBlock{
    [HJTNetTool get:[NSString stringWithFormat:@"http://www.fuli14.me/thread-%@-1-1.html",startNum] progress:nil success:^(id  _Nonnull responseObject) {
        SmallModel *model = [[SmallModel alloc] init];
        model.id = startNum;
        model.title = [self getTitle:responseObject];
        model.url = [self getUrl:responseObject];
        model.htmlUrl = [NSString stringWithFormat:@"http://www.fuli14.me/thread-%@-1-1.html",startNum];
        NSLog(@"%@",[model modelToJSONString]);
        dataBlock(model);
    } failure:^(NSString * _Nonnull errorLD) {

    }];
}

+ (NSString *)getUrl:(NSString *)string{
    NSString *string1 = [string componentsSeparatedByString:@"index.m3u8\""].firstObject;
    NSString *string2 = [string1 componentsSeparatedByString:@"src=\""].lastObject;
    return [NSString stringWithFormat:@"http://www.fuli14.me/%@index.m3u8",string2];
}

+ (NSString *)getTitle:(NSString *)string{
    NSString *string1 = [string componentsSeparatedByString:@"<title>"].lastObject;
    NSString *string2 = [string1 componentsSeparatedByString:@"</title>"].firstObject;
    return [string2 componentsSeparatedByString:@"-"].firstObject;
}

@end
